#pragma once
#include "IMsgFilter.h"

class CxWnd
{
public:
    CxWnd();
    virtual ~CxWnd();

    HWND    GetHWND();

    BOOL    Create(int x, int y, int cx, int cy, HWND hParent);
    VOID    Destroy();

    BOOL    ShowWindow(int nShow);

    BOOL    CenterWindow(HWND hWndCenter = NULL);

    DWORD   GetStyle() const;

    virtual LRESULT ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam);

    LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);

    BOOL    RegisterFilter(UINT index, IMsgFilter* filter);
    BOOL    UnregisterFilter(UINT index, IMsgFilter* filter);

    ATOM    _register_class(HINSTANCE hInstance);
    bool    _unregister_class();

protected:
    typedef std::list<xBase::CScopedRefPtr<IMsgFilter>> FILTERS;
    HWND        m_hWnd;
    FILTERS     m_ltFilters;

protected:
    static WNDCLASSEX   s_wcex_;
    static ATOM         s_atom_;
    static LONG         s_count_;
    static const TCHAR* s_classname;
    static const TCHAR* s_obj_address_;

    static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

private:
    CxWnd(const CxWnd& other);
    CxWnd & operator = (const CxWnd& other);
};